/*

	Unit tests for task class

*/

#include "../task.h"
#include <vector>



TEST(taskTest, testTaskFromString) {
	Task newTask;
	EXPECT_EQ(newTask.fromString("2013-Oct-23 08:56  false  4  "), false);
	EXPECT_EQ(newTask.fromString("false  4"), false);
	EXPECT_EQ(newTask.fromString("false  #category  "), false);
	EXPECT_EQ(newTask.fromString("false  4444  #category  200  "), false);
	EXPECT_EQ(newTask.fromString("false  4444  #category  #category2  2013-pp-23  "), false);
	EXPECT_EQ(newTask.fromString("false  4444  #category  #category2  2013-10-2333  "), false);
	EXPECT_EQ(newTask.fromString("false  4444  #category  #category2  2013-10-23 99"), false);
	EXPECT_EQ(newTask.fromString("false  4444  #category  #category2  2013-10-23  2013-10-25"), false);
	EXPECT_EQ(newTask.fromString("false  4444  #category  #category2  2013-10-23  2013-10-25  "), true);
	EXPECT_EQ(newTask.fromString("false  4  "), true);
	EXPECT_EQ(newTask.getTaskName(), "4");
	
}

TEST(task, testTaskSet) {
	Task newTask;
	EXPECT_EQ(newTask.isValid(), true);
	vector<string> c;
	Date start;
	start.fromString("tomorrow 9pm");
	Date end;
	end.fromString("tomorrow 10pm");
	newTask.setStartEnd(start, end);
	c.push_back("category1");
	c.push_back("category2");
	newTask.setTaskName("a new task");
	newTask.setCategories(c);
	EXPECT_EQ(newTask.getTaskName(), "a new task");
	EXPECT_EQ(newTask.haveCategory("category1"), newTask.haveCategory("category2"));
	EXPECT_EQ(newTask.getStart().toString(), start.toString());
	EXPECT_EQ(newTask.getEnd().toString(), end.toString());
	EXPECT_EQ(newTask.isUpcoming(), true);
	EXPECT_EQ(newTask.isOver(), false);
	newTask.setDone();
	EXPECT_EQ(newTask.isDone(), true);
}